/*
路由统一返回响应体 中间件
*/
function routerResponse() {
  return async (ctx, next) => {
    try {
      await next();
      ctx.body = {
        code: 200,
        message: "success",
        data: ctx.body,
      };
    } catch (err) {
      ctx.status = err.status || 500;
      ctx.body = {
        code: err.status || 500,
        message: err.message,
      };
    }
  };
}
module.exports = routerResponse;
